﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    [CPPEI.WebApi.AuthPostAction("ETL", "DeleteDataService", "1.0")]
    public class DeleteDataServiceAction : BaseAction<DeleteDataServiceParams, DeleteDataServiceResult>
    {
        protected override ActionResult<DeleteDataServiceResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            DeleteDataServiceParams opParams)
        {
            Logger.DebugToTag(Library.LogTAG, "DeleteDataServiceAction");

            SER.DtSerService service = new SER.DtSerService();
            ServiceResult result = service.DeleteDtSer(context.UserId, opParams.DataServiceId);
            if(result.IsSuccess)
            {
                return new ActionResult<DeleteDataServiceResult>(new DeleteDataServiceResult());
            }
            else
            {
                return new ActionResult<DeleteDataServiceResult>(result.IsSuccess, result.ErrorCode, result.Message, null);
            }
        }
    }

    public class DeleteDataServiceParams
    {
        [Parameter]
        public Guid DataServiceId { get; set; }
    }

    public class DeleteDataServiceResult
    {
    }
}
